let userCollectionAPP = new Vue({
   el:'#userCollectionAPP',
   data:{
       collections:[
           {title:'不知道',userNickName:"小明",createdTimeText:"3天前",questionId:""},
           {title:'支部不知道',userNickName:"小红",createdTimeText:"2天前",questionId:""},
           {title:'不知道不知道',userNickName:"小刚",createdTimeText:"1天前",questionId:""},
       ],
       pageInfo:[]
   },
    methods:{
        loadcollections:function (page) {
            if (!page || page<1)
                page=1;
            $.ajax({
                url:'/api/v1/userCollection/my',
                data:'page='+page,
                success:function (json) {
                    let data = json.data;
                    let collection = data.list;
                    for (let i = 0; i < collection.length; i++) {

                        collection[i].createdTimeText = getCreatedTimeText(collection[i].createdTime);
                    }

                    userCollectionAPP.collections = collection;
                    userCollectionAPP.pageInfo = data;

                }
            });
        },
        deleteCollect:function (questionId) {


            $.ajax({
                url: '/api/v1/userCollection/delect/'+questionId,
                type: 'post',
                success: function(json) {

                    if (json.state == 2000) {
                        alert("删除成功！");
                        userCollectionAPP.loadcollections();
                        // location.reload(true);
                    } else {
                        alert(json.message);
                    }
                }
            });
        }
    },
    created: function () {
        this.loadcollections();
    }
});